#ifndef DECOSOLID_H
#define DECOSOLID_H

#include "SceneObj.h"
#include "StaticMesh.h"
#include <string>
#include "FluidSparseVector.h"

class DecoRenderData;



class DecoSolidObject :
	public DecoSceneObject
{
protected:
	double m_rho;
	double m_mass;
	matrix33 m_inertia;
	vector3 m_COM;
	vector3 m_angMomentum;
	vector3 m_linMomentum;
	vector3 m_acc;
	vector3 m_vel;
	vector3 m_omg;
	DOUBLE m_currentTime;
	BOOL m_bTwowayCouple;
	FluidSparseVector m_ForceX;
	FluidSparseVector m_ForceY;
	FluidSparseVector m_ForceZ;
	FluidSparseVector m_TorqueX;
	FluidSparseVector m_TorqueY;
	FluidSparseVector m_TorqueZ;

	virtual void calculateMomentum();
	virtual void updateRigidBody(const vector3& force, const vector3& torque, DOUBLE deltaTime);
	
	void prepareCouplingMatrixForRigidBody(int dim);
	FluidSparseVector getPressureContributionToUFaceAccForRigidBody(int i, int j, int k, int dim);
	FluidSparseVector getPressureContributionToVFaceAccForRigidBody(int i, int j, int k, int dim);
	FluidSparseVector getPressureContributionToWFaceAccForRigidBody(int i, int j, int k, int dim);

public:
	DecoSolidObject(void);
	virtual ~DecoSolidObject(void);
	virtual vector3 SampleVelocity(const vector3& pos) = 0;
	virtual void Update(DOUBLE deltaTime) = 0;
	virtual void UpdateBeforeCoupling(DOUBLE deltaTime, BOOL bSimplifiedFluid = FALSE);
	virtual void calculateMass();
	virtual void calculateInertia();
	virtual void PrepareImplicitTwowayCouplingMatrix(int dim) = 0;
	virtual FluidSparseVector GetPressureContributionToUFaceAcc(int i, int j, int k, int dim) = 0;
	virtual FluidSparseVector GetPressureContributionToVFaceAcc(int i, int j, int k, int dim) = 0;
	virtual FluidSparseVector GetPressureContributionToWFaceAcc(int i, int j, int k, int dim) = 0;
	friend DecoArchive& operator<< (DecoArchive& Ar, const DecoSolidObject& obj);
	friend DecoArchive& operator>> (DecoArchive& Ar, DecoSolidObject& obj);
};


#endif



